<#include "../../page.ftl" />
<#assign shmsConstant = statics["cn.hfatec.shms.constants.ShmsConstant"]/>
<#assign security=JspTaglibs["/WEB-INF/security.tld"] />
<div class="tile-body">
    <div class="dd" id="nestable3">
    <#if organizationsTable??>
        <#list organizationsTable as organization>
            <ol class="dd-list">
                <li class="dd-item dd3-item dd-field" data-id="5">
                    <div class="dd3-content">${organization.orgName!''}
                        <div class="controls">
                            <@security.authorize ifAnyGranted="ROLE_ORG_A">
                                <a onclick="return popAddOrModify('${organization.orgId!''}','${organization.orgLevel!''}');"
                                   data-toggle="tooltip" data-placement="top" title="新增" data-original-title="新增">
                                    <i class="fa fa-plus-square-o"></i></a>
                            </@security.authorize>
                            <@security.authorize ifAnyGranted="ROLE_ORG_E">
                                <a onclick="return popEditOrModify(${organization.id!''});" data-toggle="tooltip"
                                   data-placement="top" title="编辑" data-original-title="编辑">
                                    <i class="fa fa-pencil-square-o"></i></a>
                            </@security.authorize>
                            <#if organization.parentOrgId != shmsConstant.ORG_CACHE>
                                <@security.authorize ifAnyGranted="ROLE_ORG_D">
                                    <a onclick="return deleteOrg(${organization.id!''},'${organization.orgId!''}');"
                                       data-toggle="tooltip" data-placement="top" title="删除" data-original-title="删除">
                                        <i class="fa fa-times"></i></a>
                                </@security.authorize>
                            </#if>
                        </div>
                    </div>
                    <#if organization.childrenOrgList??>
                        <#assign organizationsTable=organization.childrenOrgList/>
                        <#include "childerOrg.ftl"/>
                    </#if>
                </li>
            </ol>
        </#list>
    </#if>
    </div>
</div>
<script>
    $(function () {
        var updateOutput = function (e) {
            var list = e.length ? e : $(e.target);
            output = list.data('output');
            if (window.JSON) {
                $(output).val(window.JSON.stringify(list.nestable('serialize')));//, null, 2));
            } else {
                output.val('JSON browser support required for this demo.');
            }
        };
        $('#nestable3').nestable({
            group: 1
        }).on('change', updateOutput);
        $('.dd3-content .dropdown-menu input').click(function (e) {
            e.preventDefault();
            e.stopPropagation();
        });
    });
</script>